home *** CD-ROM | disk | FTP | other *** search
- Path: overload.lbl.gov!news
- From: Mikhail Faiguenblat <mfaiguen>
- Newsgroups: comp.lang.c
- Subject: Locaton of an array?
- Date: 12 Jan 1996 02:59:32 GMT
- Organization: Lawrence Berkeley Laboratory, Berkeley CA
- Message-ID: <4d4iqk$hs3@overload.lbl.gov>
- NNTP-Posting-Host: issserv4.lbl.gov
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.12 (X11; I; SunOS 5.4 sun4d)
- X-URL: news:comp.lang.c
-
- I am sure this has been answered a million times by now, but could someody help
- me, please?
-
- I have an array in my program, and I need to find out the absolute location in
- memory where this array is located.
- I have tried to do it this way:
-
- #include <stdio.h>
-
- int main() {
- char arr[10];
- int addr;
-
- printf("sizeof(char *) = %d\n", sizeof(char *));
- printf("sizeof(int) = %d\n", sizeof(int));
-
- addr = arr;
-
- printf("addr = %d\n", addr);
-
- return 0;
- }
-
- And it did not work:
-
- sizeof(char *) = 4
- sizeof(int) = 4
- addr = 2063810808
-
- Obviously, the computer I run it on does not have 2Gb memory, so I must be
- doing something wrong.
- Can anybody help me?
-
- Mikhail
-
-